﻿import express from "express";
import bodyParser from "body-parser";
const app = express();
const port = 3000;

app.use(bodyParser.urlencoded({extended:true}));

app.get("/",(req,res)=>{
    const today = new Date();
    const day = today.getDay();

    let bowl =["apples","oranges","pears"];

    res.render("index.ejs",{
        dayType:"a weekday",
        advice:"it is time to work hard",
        items:bowl
    });
})

app.post("/submit",(req,res)=>{
    const numLetters = req.body["fName"].length + req.body["lName"].length;
    console.log(numLetters);
    res.render("index.ejs",{
        numberOfLetters:numLetters
    });
})

app.listen(port,(req,res)=>{
    console.log(`Server running on port ${port}`);
});

